package com.greystripe.sdk;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore.Images.Media;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

final class o extends Thread
{
  o(m paramm, String paramString)
  {
  }

  public final void run()
  {
    try
    {
      URL localURL = new URL(this.a);
      URLConnection localURLConnection = localURL.openConnection();
      localURLConnection.setUseCaches(false);
      localURLConnection.getContentLength();
      int i = localURL.toString().lastIndexOf('/');
      String str = "gsImage.bin";
      if (i >= 0)
        str = localURL.toString().substring(i + 1);
      localFile = new File(c.o(this.b.a).getFilesDir(), str);
      localBufferedInputStream = new BufferedInputStream(localURLConnection.getInputStream());
      localFileOutputStream = new FileOutputStream(localFile);
      localBufferedOutputStream = new BufferedOutputStream(localFileOutputStream, 512);
      byte[] arrayOfByte = new byte[512];
      while (!isInterrupted())
      {
        int j = localBufferedInputStream.read(arrayOfByte, 0, arrayOfByte.length);
        if (j < 0)
          break;
        localBufferedOutputStream.write(arrayOfByte, 0, j);
      }
    }
    catch (MalformedURLException localMalformedURLException)
    {
      File localFile;
      BufferedInputStream localBufferedInputStream;
      FileOutputStream localFileOutputStream;
      BufferedOutputStream localBufferedOutputStream;
      localMalformedURLException.printStackTrace();
      return;
      localBufferedOutputStream.close();
      localFileOutputStream.close();
      localBufferedInputStream.close();
      if ((!isInterrupted()) && (MediaStore.Images.Media.insertImage(c.o(this.b.a).getContentResolver(), localFile.getPath(), "", "") != null))
      {
        c.o(this.b.a).sendBroadcast(new Intent("android.intent.action.MEDIA_MOUNTED", Uri.parse("file://" + Environment.getExternalStorageDirectory())));
        this.b.a.f();
      }
      localFile.delete();
      return;
    }
    catch (IOException localIOException)
    {
      localIOException.printStackTrace();
      return;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.greystripe.sdk.o
 * JD-Core Version:    0.6.2
 */